from lib.net import *


class mosmon:
    isRunning = True
    delay = 1;
    
    def recvLoop(self):
        """ A thread which receives and handles messages. """
        while self.isRunning:
            msg = recvMsg()
            self.handleMsg(msg)
           
    def main(self):
        pass;
    
    def start(self, listen=' '):
            initLogging()
            # setup networking
            initNetworking(listen, self.broadcast)
    
            # start threads and wait for them to finish
            #statusThread = thread.start_new_thread(sendStatusLoop, (defTimeout, ))
            mainThread = thread.start_new_thread(self.main, (self.delay, ))
            recvThread = thread.start_new_thread(self.recvLoop, ()